﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DrSoftsFrame.Servers;

namespace PreeRegisterDAL
{
    public class WorkGetcountDAL
    {
        public static DataSet GetWorkCountInfo(string workdate)
        {
            try
            {
                string sqlstr = string.Format(@"select ideptid,workcount=count(1),tcount=sum(isnull(nMaxDiagnoseNum,0))
                                                ,mcount=sum(isnull(nMaxPreengageNum,0)),acount=sum(isnull(nMaxPreengageNum,0)-isnull(nPreengageNum,0))
                                                from opdworkplan
                                                where convert(varchar(10),dstarttime,120) in ({0})
                                                and isnull(nMaxPreengageNum,0)>0 and isnull(nMaxDiagnoseNum,0)>0 
                                                group by ideptid", workdate);
                ClinicDb mydb = new ClinicDb();
                DataSet ds = mydb.ExecuteSelect(sqlstr);
                if (ds == null || ds.Tables.Count < 1)
                {
                    return null;
                }
                ds.Tables[0].TableName = "WorkCount";
                return ds;

            }
            catch (Exception err)
            {

                throw;
            }
        }
    }
}
